import { createSlice, createAsyncThunk } from "@reduxjs/toolkit"

export interface autoActivityType {
    autoSetActivityList: any[],
    autoSetLogsList: any[],
}


// export const getDlyUserBindInfos = createAsyncThunk('autoCounps/getDlyUserBindInfos', async (data: any, { getState, dispatch }) => {
//     return new Promise((resolve, reject) => {
//         // const getToken = localStorage.getItem('dlyUserToken')
//         // if (getToken) {
//         //     return
//         // }
//         bindinfo().then(res => {
//             console.log('binginfos', res)
//             if (res?.total) {
//                 localStorage.setItem('dlyUserToken', res.tokens.token)
//                 localStorage.setItem('dlyUserRefreshToken', res.tokens.refresh_token)
//                 saveUserJwt(res.tokens.token)
//                 // resolve(res)
//             } else {
//                 localStorage.setItem('dlyUserToken', '')
//                 localStorage.setItem('dlyUserRefreshToken', '')
//             }
//             resolve(res)
//         })
//     })
// })


// 列表获取 后期异步获取数据 修改缓存
const autoActivity = createSlice({
    name: "jinritemaiAutoActivity",
    initialState: <autoActivityType>{
        autoSetActivityList: [],
        autoSetLogsList: [],
    },
    reducers: {
        setAutoActivityListStor: (start, action: { payload: any[] }) => {
            start.autoSetActivityList = action.payload
        },
        setAutoLogsListStor: (start, action: { payload: any[] }) => {
            start.autoSetLogsList = action.payload
        }
    },
    // extraReducers: (builder) => {

    //     builder.addCase(getDlyUserBindInfos.fulfilled, (start, action: { payload: any }) => {
    //         // console.log('action.payloadaction.payload', action.payload)
    //         // start.peodecuList = action.payload
    //         // start.getprodectStatus = false
    //         // // start.getprodectStatus = true
    //         // console.log('getDatas', action.payload)
    //     })

    // },
})

export const { setAutoActivityListStor, setAutoLogsListStor } = autoActivity.actions

export default autoActivity.reducer